{
int rc = 0;
unsigned int i;
+ XEN_GUEST_HANDLE(void) cnt_uop;
+ set_xen_guest_handle(cnt_uop, NULL);
switch ( cmd )
{
#define CASE(name) \
return do_grant_table_op(cmd, cmp_uop, count);
}
- if ( count > 512 )
+ if ( (int)count < 0 )
rc = -EINVAL;
for ( i = 0; i < count && rc == 0; )
rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1);
}
}
+ ASSERT(rc <= 0);
if ( rc == 0 )
{
#define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \
}
if ( rc == 0 )
rc = gnttab_transfer(guest_handle_cast(nat.uop, gnttab_transfer_t), n);
- if ( rc == 0 )
+ if ( rc > 0 )
+ {
+ ASSERT(rc < n);
+ i -= n - rc;
+ n = rc;
+ }
+ if ( rc >= 0 )
{
XEN_GUEST_HANDLE(gnttab_transfer_compat_t) xfer;
xfer = guest_handle_cast(cmp_uop, gnttab_transfer_compat_t);
guest_handle_add_offset(xfer, i);
+ cnt_uop = guest_handle_cast(xfer, void);
while ( n-- )
{
guest_handle_add_offset(xfer, -1);
}
if ( rc == 0 )
rc = gnttab_copy(guest_handle_cast(nat.uop, gnttab_copy_t), n);
- if ( rc == 0 )
+ if ( rc > 0 )
+ {
+ ASSERT(rc < n);
+ i -= n - rc;
+ n = rc;
+ }
+ if ( rc >= 0 )
{
XEN_GUEST_HANDLE(gnttab_copy_compat_t) copy;
copy = guest_handle_cast(cmp_uop, gnttab_copy_compat_t);
guest_handle_add_offset(copy, i);
+ cnt_uop = guest_handle_cast(copy, void);
while ( n-- )
{
guest_handle_add_offset(copy, -1);
}
}
+ if ( rc > 0 )
+ {
+ ASSERT(i < count);
+ ASSERT(!guest_handle_is_null(cnt_uop));
+ rc = hypercall_create_continuation(__HYPERVISOR_grant_table_op,
+ "ihi", cmd, cnt_uop, count - i);
+ }
+
return rc;
}
#include <xen/lib.h>
#include <xen/sched.h>
#include <xen/mm.h>
+#include <xen/event.h>
#include <xen/trace.h>
#include <xen/guest_access.h>
#include <xen/domain_page.h>
for ( i = 0; i < count; i++ )
{
+ if (i && hypercall_preempt_check())
+ return i;
if ( unlikely(__copy_from_guest_offset(&op, uop, i, 1)) )
return -EFAULT;
__gnttab_map_grant_ref(&op);
count -= c;
done += c;
+
+ if (count && hypercall_preempt_check())
+ return done;
}
return 0;
count -= c;
done += c;
+
+ if (count && hypercall_preempt_check())
+ return done;
}
return 0;
for ( i = 0; i < count; i++ )
{
+ if (i && hypercall_preempt_check())
+ return i;
+
/* Read from caller address space. */
if ( unlikely(__copy_from_guest_offset(&gop, uop, i, 1)) )
{
for ( i = 0; i < count; i++ )
{
+ if (i && hypercall_preempt_check())
+ return i;
if ( unlikely(__copy_from_guest_offset(&op, uop, i, 1)) )
return -EFAULT;
__gnttab_copy(&op);
long rc;
struct domain *d = current->domain;
- if ( count > 512 )
+ if ( (int)count < 0 )
return -EINVAL;
domain_lock(d);
if ( unlikely(!guest_handle_okay(map, count)) )
goto out;
rc = gnttab_map_grant_ref(map, count);
+ if ( rc > 0 )
+ {
+ guest_handle_add_offset(map, rc);
+ uop = guest_handle_cast(map, void);
+ }
break;
}
case GNTTABOP_unmap_grant_ref:
if ( unlikely(!guest_handle_okay(unmap, count)) )
goto out;
rc = gnttab_unmap_grant_ref(unmap, count);
+ if ( rc > 0 )
+ {
+ guest_handle_add_offset(unmap, rc);
+ uop = guest_handle_cast(unmap, void);
+ }
break;
}
case GNTTABOP_unmap_and_replace:
if ( unlikely(!replace_grant_supported()) )
goto out;
rc = gnttab_unmap_and_replace(unmap, count);
+ if ( rc > 0 )
+ {
+ guest_handle_add_offset(unmap, rc);
+ uop = guest_handle_cast(unmap, void);
+ }
break;
}
case GNTTABOP_setup_table:
{
rc = gnttab_setup_table(
guest_handle_cast(uop, gnttab_setup_table_t), count);
+ ASSERT(rc <= 0);
break;
}
case GNTTABOP_transfer:
if ( unlikely(!guest_handle_okay(transfer, count)) )
goto out;
rc = gnttab_transfer(transfer, count);
+ if ( rc > 0 )
+ {
+ guest_handle_add_offset(transfer, rc);
+ uop = guest_handle_cast(transfer, void);
+ }
break;
}
case GNTTABOP_copy:
if ( unlikely(!guest_handle_okay(copy, count)) )
goto out;
rc = gnttab_copy(copy, count);
+ if ( rc > 0 )
+ {
+ guest_handle_add_offset(copy, rc);
+ uop = guest_handle_cast(copy, void);
+ }
break;
}
case GNTTABOP_query_size:
{
rc = gnttab_query_size(
guest_handle_cast(uop, gnttab_query_size_t), count);
+ ASSERT(rc <= 0);
break;
}
default:
out:
domain_unlock(d);
+
+ if ( rc > 0 )
+ {
+ ASSERT(rc < count);
+ rc = hypercall_create_continuation(__HYPERVISOR_grant_table_op,
+ "ihi", cmd, uop, count - rc);
+ }
return rc;
}